<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>清除浮动方法3</title>

    <style>
        * {
            padding: 0;
            margin: 0;
        }
        /* <!-- 清除浮动方法3：给父级添加after --> */
        .clearfix:after {
            content: "";
            display: block;
            height: 0;
            clear: both;
            visibility: hidden;
        }
        .clearfix {
            zoom: 1;
        }

        .box {

            width: 900px;
            background-color: gray;
            /* border: 1px solid blue; */
        }

        .box1 {
            float: left;
            width: 200px;
            height: 100px;
            background-color: red;
        }

        .box2 {
            float: left;
            width: 400px;
            height: 100px;
            background-color: purple;
        }

        .footer {
            width: 1000px;
            height: 250px;
            background-color: skyblue;
        }
    </style>
</head>

<body>
    /* <!-- 清除浮动方法3：给父级添加after --> */
    <div class="box clearfix">
        <div class="box1">大猫</div>
        <div class="box2">小猫</div>

    </div>
    <div class="footer"></div>
</body>

</html>